/*******************************************************************************
    Universidad del Valle de Guatemala
    Algoritmos y estructuras de datos
    Karen Tojin   08091
    Fecha: 15 de Agosto de 2009
    Descricion: Programa que crea un árbol de Huffman.
***************************************************************************** */

/**
 *
 * @author karenAndy
 */
public class TreeNode<T> {
    private String binaryCode;
    private int frequency;
    private T character;
    private TreeNode<T> left, right;

    //Constructor for the tree node, sets the frequency and the correspondant character
    public TreeNode(T character, int frequency){
        this.character=character;
        this.frequency=frequency;
    }

    //Constructor for the tree node, sets the frequency and the correspondant character
    public TreeNode(T character){
        this.character=character;
        this.frequency=1;
    }

    //Setter for character
    public void setCharacter(T character) {
        this.character=character;
    }

    //Getter for character
    public T getCharacter() {
        return character;
    }

    //Setter for frequency
    public void setFrequency(int frequency){
        this.frequency=frequency;
    }

    //Getter for frequency
    public int getFrequency(){
        return frequency;
    }

    //Setter for the left child
    public void setLeftChild(TreeNode left) {
        this.left=left;
    }

    //Getter for the left child
    public TreeNode getLeftChild() {
        return left;
    }

    //Setter for the right child
    public void setRightChild(TreeNode right) {
        this.right=right;
    }

    //Getter for the right child
    public TreeNode getRightChild() {
        return right;
    }

    //toString method
    @Override
    public String toString(){
        String charName="";
        charName+=getCharacter();
        return charName;
    }
}
